package com.hws.leetcode.Day_01_13;

import java.util.Arrays;

/**
 * ClassName:leetcode_747
 * Package:com.hws.leetcode.Day_01_13
 * Description:
 *
 * @ date:2022/1/13 18:07
 * @ author:hws
 */
public class leetcode_747 {

    public int dominantIndex(int[] nums) {
        if (nums == null || nums.length == 1) {
            return 0;
        }
        int maxIndex = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[maxIndex] < nums[i]) {
                maxIndex = i;
            }
        }
        Arrays.sort(nums);
        return nums[nums.length - 1] >= (2 * nums[nums.length - 2]) ? maxIndex : -1;
    }

    public static void main(String[] args) {
        leetcode_747 lc = new leetcode_747();
        int[] nums = new int[]{1};
        System.out.println(lc.dominantIndex(nums));
    }

}
